package cn.wolfcode.trip.base.service.impl;

import cn.wolfcode.trip.base.domain.Together;
import cn.wolfcode.trip.base.mapper.TogetherMapper;
import cn.wolfcode.trip.base.query.QueryObject;
import cn.wolfcode.trip.base.service.IInformationService;
import cn.wolfcode.trip.base.service.ITogetherService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TogetherServiceImpl implements ITogetherService {
    @Autowired
    private TogetherMapper togetherMapper;

    @Autowired
    private IInformationService informationService;

    @Override
    public void save(Together together) {
        //添加游记基本信息
        togetherMapper.insert(together);
    }

    @Override
    public Together get(Long id) {
        return togetherMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<Together> listAll() {
        return togetherMapper.selectAll();
    }

    @Override
    public void update(Together together) {
        togetherMapper.updateByPrimaryKey(together);

    }


    @Override
    public PageInfo queryForList(QueryObject qo) {
        PageHelper.startPage(qo.getCurrentPage(), qo.getPageSize(), true, false, true);
        List<Together> list = togetherMapper.queryForList(qo);
        return new PageInfo(list);
    }


}
